<?php
/**
 * @user: leo
 * @date: 2021/5/17
 * @createTime: 14:37
 * @company: 迈酷网络科技 http://www.maicooit.com
 */
namespace app\admin\model;

use think\Model;

class UserData extends Model
{
    public function UserDataFindByIdModel($id){
        $where[] = ['user_id','=',$id];
        $info = $this->field('*')->where($where)->find();
        return $info;
    }
    //列表
    public function UserDataListModel($key,$domain,$page,$pagesize){
        $field = '*';
        $list = $this->alias('u')
            ->where('domain','=',$domain)
            ->field($field)
            ->paginate([
                'list_rows'=> $pagesize,
                'var_page' => 'page',
                'page'=>$page
            ]);
        return $list;
    }
    //新增
    public function UserDataInsertModel($UserInfo){
        return $this->insertGetId($UserInfo);
    }
    //保存
    public function UserDataSaveModel($userid,$userInfo){
        $where[] = ['user_id','=',$userid];
        $res = $this->where($where)->save($userInfo);
        return $res;
    }
    //启用、禁用
    public function UserDataDisableEableModel($userid){
        $where[] = ['user_id','=',$userid];
        $data['status'] = -1;
        $res = $this->where($where)->save($data);
        return $res;
    }
    //删除
    public function UserDatadelModel($userid){
        $where[] = ['user_id','=',$userid];
        $res = $this->where($where)->delete();
        return $res;
    }
}
